#ifndef __GLOBAL_H
#define __GLOBAL_H

#include "stm32f1xx_hal.h"
#include <stdlib.h>
#include "math.h"



#define HIGH 1
#define LOW 0

#define LG_min(a,b) ((a)<(b)?(a):(b))
#define LG_max(a,b) ((a)>(b)?(a):(b))
#define LG_abs(x) ((x)>0?(x):-(x))
#define LG_constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define LG_round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define LG_radians(deg) ((deg)*DEG_TO_RAD)
#define LG_degrees(rad) ((rad)*RAD_TO_DEG)
#define LG_sq(x) ((x)*(x))
#define LG_swap(a, b) { int16_t t = a; a = b; b = t; }

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;

void delay_us(uint32_t udelay);
u16 RGB24toRGB16(u32 RGB32);

void reverse(char *str, int len);
int intToStr(int x, char str[], int d);
void ftoa(float n, char *res, int afterpoint);

#endif
